import { BlockVolume } from "@minecraft/server";

export function insetVolume(volume: BlockVolume, thickness: number = 1): BlockVolume | null {
    const max = volume.getMax();
    const min = volume.getMin();

    const newMin = { x: min.x + thickness, y: min.y + thickness, z: min.z + thickness };
    const newMax = { x: max.x - thickness, y: max.y - thickness, z: max.z - thickness };

    if (newMin.x > newMax.x || newMin.y > newMax.y || newMin.z > newMax.z) {
        return null;
    }

    return new BlockVolume(newMin, newMax);
}
